
package com.sport.booking.controller;

import com.sport.booking.model.User;
import com.sport.booking.service.UserService;
import com.sport.booking.util.WxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/users")
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private WxService wxService;
    @PostMapping("/register")
    public User register(@RequestBody User user) {
        return userService.register(user);
    }

    @PostMapping("/login")
    public User login(@RequestParam String username, @RequestParam String password) {

        return userService.login(username, password);
    }


    @PostMapping("/getOpenId")
    public String getOpenId(@RequestParam String code) {

        return wxService.getOpenId(code);
    }
}
